package com.yunwaikeji.gy_tool_library_test

import androidx.lifecycle.MutableLiveData
import com.yunwaikeji.gy_tool_library.mvvm.net.GYStateModel
import com.yunwaikeji.gy_tool_library.mvvm.net.GYStateType

fun <T> BaseResponseModel<T>.dataConvert(
    liveData: MutableLiveData<T>,
    stateData: MutableLiveData<GYStateModel>
): BaseResponseModel<T> {
    if (code == 200) {
        liveData.value = this.data
        stateData.value = GYStateModel(GYStateType.SUCCESS, "成功了")
    } else {
        stateData.value = GYStateModel(GYStateType.ERROR, "失败了")
    }
    return this
}
